package com.java.jvm.loader;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

public class SimpleUrlClassLoaderTests {
    public static void main(String[] args) throws MalformedURLException, ClassNotFoundException {
        File file=new File("E:\\TCGBIV\\DEVCODES\\jht2206");
        URL[] urls={file.toURI().toURL()};
        //你自己写类加载？(你为什么要写这个类加载器你是不是要知道)
        SimpleUrlClassLoader classLoader1=
                new SimpleUrlClassLoader(urls,
                        ClassLoader.getSystemClassLoader());//自己指定parent

        Class<?> aClass1 = classLoader1.loadClass("pkg.HelloJVM");
        System.out.println(aClass1.getClassLoader());
        System.out.println(aClass1.getClassLoader().getParent());

        SimpleUrlClassLoader classLoader2=
                new SimpleUrlClassLoader(urls,
                        ClassLoader.getSystemClassLoader());
        Class<?> aClass2=Class.forName("pkg.HelloJVM",
                true,
                classLoader2);

        System.out.println(aClass1==aClass2);

    }
}
